Ext.onReady(function(){
	Demo.initPage();
});
var Demo = {
		initPage: function(){
			Ext.create('Ext.container.Viewport', {
			    layout: 'border',
			    frame:false,
			    border:false,
			    items: [{
			    	id: 'leftPanel',
			    	region: 'west',
			    	layout: 'fit',
			    	width: 220,
			    	items: [Demo.createTree()]
			    },{
			    	id: 'mainPanel',
			        region: 'center',
			        layout: 'fit',
			        items:[Demo.createGrid()]
			    }]
			});
		},
		createTree: function(){
			//树
		 	var tree = Ext.create("Ext.com.bkfm.tree",{
		 		id: "regionTree",
		 		rootVisible: true,
		 		rootLabel: "中国",
		 		treeConfigId: "region",
		 		rootTreeId: "000000",
		 		objPath: 'ROOT/XTCS/T_BKFM_KJCS',
		 		border: false,
		 		autoScroll: true,
		 		tbar:[{
		 			text: '新增',
		 			iconCls: 'add',
		 			handler: function(){
		 				//REGION_DISK.editTree();
		 			}
		 		},{
		 			text: '修改',
		 			iconCls: 'edit',
		 			handler: function(){
		 				//var menuTree = Ext.getCmp("regionTree");
		 				//REGION_DISK.editTree(menuTree.getSelectNode());
		 			}
		 		},{
		 			text: '删除',
		 			iconCls: 'delete',
		 			handler: function(){
		 				//var menuTree = Ext.getCmp("menuTree");
	 					//menuTree.delSelectNode(menuTree.getSelectNode());
		 			}
		 		}],
		 		viewConfig:{
		            plugins :{
		                ptype:'treeviewdragdrop',
		                //appendOnly:true         //只能拖着带非叶节点上
		            },
		            listeners:{//监听器
		                drop:function(node,data,overModel,dropPosition,options){
		                    return false;
		                },
		                beforedrop:function(node,data,overModel,dropPosition,dropFunction,options){
		                	return false;
		                }
		            }
		        }
		 	});
		 	tree.on("itemclick",function(view,record,item,index,e,opts){
		 		var region_no = record.get("id");
		 		//var title = record.get("text");
		 		//var isleaf = record.get("leaf");
		 		//var menuRoleGrid = Ext.getCmp("menuRoleGrid");
		 		//menuRoleGrid.search(" MENU_RWID='"+id+"'");
		 		//var regionGrid = Ext.getCmp("region_grid");
		 		//regionGrid.search(" FATHER_REGION_NO='"+region_no+"'");

		 	})
		 	return tree;
		},
		createGrid: function(){
			var grid = Ext.create('Ext.com.bkfm.datagrid', {
				id: "grid",
				objPath : "ROOT/XTCS/T_BKFM_KJCS",
				border: true,
				//orderby : ' ORDER BY WXRQ DESC',
				customBtn: ['车牌号码',{
					xtype: 'textfield',
					id: 's_cphm',
					width: 100
				},'付款状态',new Ext.com.bkfm.combobox({
					id: 's_fkzt',
					objPath: 'ROOT/YWGLPT/QCWX/T_BKFM_CAR_MANAGER/FKZT',
					width: 100
				}),'维修日期',{
					xtype: 'datefield',
					format: 'Y',
					width: 100,
					id: 's_wxrq_start'
				},'至',{
					xtype: 'datefield',
					format: 'Y-m-d',
					width: 100,
					id: 's_wxrq_end'
				},{
					text: '查询',
					iconCls: 'search',
					handler: function(){
						/*var s_cphm = Ext.getCmp("s_cphm").getValue();
						var s_fkzt = Ext.getCmp("s_fkzt").getValue();
						var s_wxrq_start = Ext.getCmp("s_wxrq_start").getRawValue();
						var s_wxrq_end = Ext.getCmp("s_wxrq_end").getRawValue();
						var filter = "";
						if(!Ext.isEmpty(s_cphm)){
							filter += " and cphm like '%"+Ext.util.Format.uppercase(s_cphm)+"%'";
						}
						if(!Ext.isEmpty(s_fkzt)){
							filter += " and fkzt='"+s_fkzt+"'";
						}
						if(!Ext.isEmpty(s_wxrq_start)){
							filter +=" and wxrq >='"+s_wxrq_start+"'";
						}
						if(!Ext.isEmpty(s_wxrq_end)){
							filter +=" and wxrq <='"+s_wxrq_end+"'";
						}
						Ext.getCmp("car_checkin").search(filter);*/
					}
				},'-',{
					text: '打印',
					iconCls: 'print',
					handler: function(){
						/*var record = cargrid.getSelectedRecords();
						if(record.length>0){
							window.open(CONTEXT.contextPath+"/web/business/car/print.jsp?rwid="+record[0].getId())
						}else{
							AjaxUtils.showError("请选择需要打印的记录");
						}*/
					}
				}]
			});
			return grid;
		}
};